from flask import session,g
#
#
# def rankFilters(index):
#     if(1==index):
#         return 'first'
#     elif(2==index):
#         return 'second'
#     elif(3==index):
#         return 'third'
#     else:
#         return ''



import functools

def login_required(f):
    @functools.wraps(f)
    def wrapper(*args,**kwargs):
        user_id = session.get("user_id")
        # 通过id获取用户信息
        user = None
        if user_id:
            from info.models import User
            user = User.query.get(user_id)
        g.user = user
        return f(*args,**kwargs)
    return wrapper

